<?php
include_once("../libs/com/com.php");

$cn=new comm();


//登录
function admin_login($userid,$password){
	global $mc;
	global $db;
	global $dbs;
	
if($userid=="" || $password==""){
 	return "0|userid or passoword is null";
 }
 
if($userid!="" && $password!="")
{
	
$mb=$db->ds("select * from member_content where userid='".trim($userid)."' and password ='".strtoupper(md5(trim($password)))."'");
	if(count($mb)>0)
	{
	 $db->cmd("update member_content set hit=hit+1,logintime='".date("Y-m-d H:i:s",time())."' where userno=".trim($mb[0]["userno"]));
      return "2|login is ok,userno=".trim($mb[0]["userno"]).",username=".trim($mb[0]["username"]).",rootid=".trim($mb[0]["rootid"]).",gyid=".trim($mb[0]["gyid"]);
	}
	
	else 
	{
 return "1|userid or password is wrong";
	}
}
}
if($mc->Ismp($_POST["logbtn"])!=""){
$userid=$_POST['userid'];
$password=$_POST['password'];
$log=admin_login($_POST["userid"],$_POST["password"]);

if(ereg("login is ok",$log)==1){
setcookie("userid",trim($_POST["userid"]),time()+3600*24*5000,"/");
setcookie("password",trim($_POST["password"]),time()+3600*24*5000,"/");
$msg0=split(',userno=',$log);
$msg1=split(',username=',$msg0[1]);
$msg2=split(',gyid=',$msg1[1]);//用户信息的数组
$_SESSION["member_member"][0]["userno"]=$msg1[0];
$_SESSION["member_member"][0]["username"]=$msg2[0];
$_SESSION["member_member"][0]["gyid"]=$msg2[1];
$_SESSION["member_member"][0]["userid"]=$userid;
$_SESSION["member_member"][0]["password"]=$password;
if($msg2[1]>0){
	exit("gylog is ok");
}
}
echo $log;
}



if($mc->Ismp($_POST['regbtn'])!=""){
$url='/shopapi/reg.php';
$userid=$_POST['userid'];
$password=$_POST['password'];
$email=$_POST['email'];

//$argv=Array("userid"=> $userid,"password"=>$password,"email"=>$email);
$reg=$proxy->reg($userid,$password,$email);

if(ereg("userid is exit",$reg)==1){
	echo "userid is exit";
}
if(ereg("reg is ok",$reg)==1)
{$msg0=split(',userno=',$reg);
$_SESSION["msg"]["userno"]=$msg0[1];
$_SESSION["msg"]["userid"]=$userid;
$_SESSION["msg"]["username"]=$userid;
$_SESSION["msg"]["password"]=$password;
echo "reg is ok,".$msg0[1].",".$password;
}
if(ereg("reg no",$reg)==1){
echo "reg no";
}


}





if($mc->Ismp($_POST['show'])!=""){
if($_SESSION["msg"]["userid"]!=""){
$arr['userid']=$_SESSION["msg"]["userid"];
$arr['password']=$_SESSION["msg"]["password"];
$arr['userno']=$_SESSION["msg"]["userno"];
$arr['username']=$_SESSION["msg"]["username"];
}
echo json_encode($arr);
}

?>